<template>
	<view class="app-string e-rela">
		<image class="app-string__bg" :src="$staticPath('string/string_bg.png')" mode="widthFix"></image>
		<view class="app-string__content">
			<view class="e-p-l-20 e-p-r-20">
				<view class="app-string__panel e-m-b-24 e-p-20">
					<view class="e-m-b-20 e-flex ">
						<view class="e-flex-1 e-p-l-60 e-m-r-30 e-p-t-34 app-string__panel--box">
							<view class="e-m-b-14 w-500 e-font-34 c-white">
								{{info.packNumber || 0}}
							</view>
							<view class="w-500 e-font-28" style="color: #FFD892;">
								数量
							</view>
						</view>
						<view class="e-flex-1 e-p-l-60 e-p-t-34 app-string__panel--box">
							<view class="e-m-b-14 w-500 e-font-34 c-white">
								{{info.mdFreezeMoney || 0}}
							</view>
							<view class="w-500 e-font-28" style="color: #FFD892;">
								摩豆
							</view>
						</view>
					</view>
					<view class="e-flex ">
						<view class="e-flex-1 e-p-l-60 e-m-r-30 e-p-t-34 app-string__panel--box">
							<view class="e-m-b-14 w-500 e-font-34 c-white">
								{{info.freezeMoney || 0}}
							</view>
							<view class="w-500 e-font-28" style="color: #FFD892;">
								冻结积分
							</view>
						</view>
						<view class="e-flex-1 e-p-l-60 e-p-t-34 app-string__panel--box" @tap="$goTo('/pages/user/wallet/currency?id=xiaofeijifen')">
							<view class="e-m-b-14 w-500 e-font-34 c-white">
								{{info.totalMoney || 0}}
							</view>
							<view class="w-500 e-font-28" style="color: #FFD892;">
								积分记录
							</view>
						</view>
					</view>
				</view>
				<view class="e-flex-xy-center">
					<image class="img-458" :src="$staticPath('string/yhbtn.png')" mode="widthFix" @tap="$goTo('/pages/string/release')"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { useUser } from '@/common/stores';
	import { storeToRefs } from 'pinia';
	import { onShow } from '@dcloudio/uni-app';
	import {  useLogin } from '@/common/hooks';
	import {getDayLog,postSupperAppLogin} from '@/common/request/api'
	
	const { isLogin } = storeToRefs(useUser());
	const { login } = useLogin();
	
	const info = ref({})
	const appLogin = () => {
		return new Promise((resolve,reject) => {
			// #ifdef APP
			uni.sendNativeEvent(
				'autoLogin',
				{
					msg: 'sendAutoLogin'
				},
				(ret) => {
					let params = {
						code: ret,
						salt: uni.getStorageSync('userSalt')
					};
					postSupperAppLogin(params)
						.then(async (res) => {
							uni.removeStorageSync('userSalt');
							await login(res.data.access_token);
							resolve()
							
						})
						.catch((err) => {
							reject(err);
						})
				}
			);
			return ;
			// #endif
			resolve()
		})
	}
	const getData = () => {
		getDayLog().then(res => {
			info.value = res.data
		})
	}
	onShow(async () => {
		if(!isLogin.value){
			await appLogin()
		}
		getData()
	})
</script>

<style lang="scss" scoped>
	@include appBem_b(string) {
		@include appBem_e(bg) {
			width: 100vw;
		}
		@include appBem_e(content) {
			position: fixed;
			bottom: 100rpx;
			width: 100vw;
		}
		@include appBem_e(panel) {
			height: 400rpx;
			background: linear-gradient( 180deg, #404452 0%, #1B1C22 100%);
			border-radius: 20rpx;
			@include appBem_m(box) {
				height: 170rpx;
				background: #454959;
				border-radius: 10rpx;
			}
		}
	}
	.img-458 {
		width: 458rpx;
	}
</style>